
function copytxt(enterId,inputId) {	
	var input= document.getElementById(inputId);	
	input.value = enterId.value;
	
}
function onAddNewUser(frmID, page)
{
	var newId = '';
	var content = null;
	var ret = 2;
	$(frmID).request(
		{	
			asynchronous: false,
			parameters: $(frmID).serialize(true),
	  		onComplete: function(transport)
	  		{ 
			  	var response = transport.responseText || "";
				var pos=response.indexOf('<!');
				content=response.substring(0,pos);
		    	//alert(content);
		    	if(content != "")
		    	{
		    		obj = content.evalJSON();
		    		ret=0;
					arr = obj.message;
					for (key in arr){
						var diverr= document.getElementById('err_'+key);
						if(diverr && arr[key]!=""){
							diverr.update(arr[key]);
							diverr.style.display ="block";
               			//alert(key); 
						}else{
							diverr.update('');	
							diverr.style.display ="none";	
						}
					}
					
		    	}
		    	if(content == "")
		    	{
		    		ret=2;
		    	}
	  		}
		});
	//alert(ret);
	if(ret==2)
	{
		document.location = page;
	}
	return false;
}

function onCheckError(Id, url,passID)
{
	var post = '';
	var pass= document.getElementById(passID);
	var frame= document.getElementById('err_'+Id.id);
	if(frame.style.display=="block"){
		if(passID!='')
			post = '&'+passID+'='+pass.value;
		new Ajax.Request(url, {
		  method: 'post',
		  asynchronous: false,
		  parameters:'act=checkerror&'+Id.id+'=' + Id.value+post,
		  onSuccess: function(transport) {
					var response = transport.responseText || "";
					var pos=response.indexOf('<!');
					content=response.substring(0,pos);
					//alert(content);
					if(content != "")
					{
						obj = content.evalJSON();
						arr = obj.message;
						for (key in arr){
							var diverr= document.getElementById('err_'+key);
								if(key==Id.id){	
									if(diverr && arr[key]!=""){
										diverr.update(arr[key]);
										diverr.style.display ="block";
										
									}else{
										diverr.update('Ok');
										diverr.className='check_ok';
										
										//diverr.style.display ="none";	
									}
								}
						}
						
					}
			}
		});
	}
	Id.className ="textinput";
	return false;
}

function onKey(ID,class)
{
	ID.className=class;
}
